package com.action;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

import com.beans.Manufacturer;
import com.hibernate.HibernateUtil;
import com.opensymphony.xwork2.ActionSupport;


public class ManufacturerListAction extends ActionSupport {
	
	private static final long serialVersionUID = 1L;
	private List<Manufacturer> ManuList;
	
	
	@SuppressWarnings("unchecked")
	public String performList() {
		Session session = HibernateUtil.getInstance().openSession();
		Transaction transaction = null;
		try {
			transaction = session.beginTransaction();
			Criteria criteria = session.createCriteria(Manufacturer.class);
			ManuList = criteria.list();
			transaction.commit();
		} catch (HibernateException e) {
			transaction.rollback();
			e.printStackTrace();
		} finally {
			session.close();
		}

		return SUCCESS;
	}
	public void setManuList(List<Manufacturer> manuList) {
		ManuList = manuList;
	}
	public List<Manufacturer> getManuList() {
		return ManuList;
	}

}
